//
//  FamilyManageTwoCell.m
//  AILock
//
//  Created by 谭亚明 on 2020/6/29.
//  Copyright © 2020 tym. All rights reserved.
//

#import "FamilyManageTwoCell.h"
#import "Masonry.h"
#import "Colors.h"
#import "Sizes.h"
#import "UIView+ZFFrame.h"
#import "Fonts.h"
#import "TYMLabel.h"
#import "TYMButton.h"

@interface FamilyManageTwoCell()

@property(nonatomic,weak) TYMLabel *sectionLab;
@property(nonatomic,weak) UIView *lineView;

@property(nonatomic,weak) UIView *conView;


@property(nonatomic,weak) UIImageView *rightImage;
@end

@implementation FamilyManageTwoCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}

-(void)initUI{
    
    TYMLabel *sctLab = [TYMLabel lb_text:@"家庭信息" font:Font_Regular(15) color:rgba(155, 155, 155)];
    sctLab.frame = CGRectMake(15, 0, 200, 44);
    [self.contentView addSubview:sctLab];
    self.sectionLab = sctLab;
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 44, ScreenWidth- 30 , 1)];
    line.backgroundColor = rgba(242, 242, 242);
    [self.contentView addSubview:line];
    self.lineView = line;
    
    UIView *conView = [[UIView alloc] initWithFrame:CGRectMake(0, 54, ScreenWidth - 30, 70)];
    [self.contentView addSubview:conView];
    self.conView = conView;
    
    TYMLabel *titLab = [TYMLabel lb_text:@"家庭" font:Font_Medium(15) color:rgba(74, 74, 74)];
    titLab.frame = CGRectMake(15, 10, 150, 21 );
    [self.conView addSubview:titLab];
    self.titLab = titLab;
    
    UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_list_more"]];
    image.frame = CGRectMake(ScreenWidth - 40-18, 11.5, 18, 18);
    [self.conView addSubview:image];
    self.rightImage = image;
    
    TYMLabel *lab = [TYMLabel lb_text:@"内容" font:Font_Regular(15) color:rgba(155, 155, 155)];
    lab.textAlignment = NSTextAlignmentRight;
    lab.frame = CGRectMake(ScreenWidth - 18- 40 - 160, 10, 160, 21);
    [self.conView addSubview:lab];
    
    UIImageView *headImage = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenWidth - 18-40 - 31, 5, 31, 31)];
    headImage.contentMode = UIViewContentModeScaleAspectFill;
    headImage.layer.masksToBounds = YES;
    headImage.layer.cornerRadius = 31/2;
    [self.conView addSubview:headImage];
    
    self.headImage = headImage;
    
    self.conLab = lab;
}

-(void)setRightImageIshiden:(BOOL)hidden{
    self.rightImage.hidden = !hidden;
    if (!hidden) {
        
        self.conLab.frame = CGRectMake(ScreenWidth - 40 - 160, 10, 160, 21);
        self.headImage.frame = CGRectMake(ScreenWidth - 40 - 31, 5, 31, 31);
    }else{
        self.conLab.frame = CGRectMake(ScreenWidth - 18- 40 - 160, 10, 160,21);
        self.headImage.frame = CGRectMake(ScreenWidth - 18- 40 - 31, 5, 31, 31);
    }
    
}

-(void)hiddenSectionView{
    self.sectionLab.hidden = YES;
    self.lineView.hidden = YES;
    
    self.conView.frame = CGRectMake(0, 0, ScreenWidth - 30, 41);
}

-(void)showSectionView{
    self.sectionLab.hidden = NO;
    self.lineView.hidden = NO;
    
    self.conView.frame = CGRectMake(0,54, ScreenWidth - 30, 41);
}

+(NSString*)identifier{
    return @"FamilyManageTwoCell";
}

+(CGFloat)cellForHeight{
    return 41;
}


@end
